﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TSqlServer;
public partial class log_LogListAll : System.Web.UI.Page
{
    public string typeid;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["opration"] != null)
        {
            switch (Request["opration"].ToString())
            {
                case "show":
                    Bind();
                    break;
                case "del":
                    if (Request["typeid"] != null)
                    {
                        typeid = Request["typeid"].ToString();
                    }
                    if (Request["id"] != null)
                    {
                        Del(Request["id"].ToString());
                    }
                    Bind();
                    break;
            }

        }
    }
    public void Bind()
    {
        string sSql;
        sSql = "select * from t_log_info as a where status=1 and (((select authority from t_log_type where id=a.typeid)=1  and a.authority=0) or a.authority=1) order by intime desc ";
        
        TSqlDBReader myReader = new TSqlDBReader(sSql);
        dlTable.DataSource = myReader.FDataReader;
        dlTable.DataBind();
        //关闭
        myReader.Free();
    }
    public void Del(string id)
    {
        TLogInfo.DeleteByID(id);
    }


    protected void dlTable_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.FindControl("hfuser") != null)
        {
            string user = ((HiddenField)e.Item.FindControl("hfuser")).Value;
            if (user != Session["userid"].ToString())
                if (e.Item.FindControl("sp1") != null)
                    e.Item.FindControl("sp1").Visible = false;
        }
    }
}
